package com.lkbaby.service;

import com.lkbaby.pojo.Dept;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

// 服务降级
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {
	@Override
	public DeptClientService create(Throwable cause) {
		return new DeptClientService() {
			@Override
			public boolean addDept(Dept dept) {
				return false;
			}

			@Override
			public Dept queryDeptByID(Long id) {
				return new Dept()
						.setDeptno(id)
						.setDname("找不到id: " + id + "对应信息，因为服务已被降级")
						.setDbSource("no database");
			}

			@Override
			public List<Dept> queryAll() {
				return null;
			}
		};
	}
}
